package cn.lx.config;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
* @Author: 落雪
* @Date: 2025/3/14 09:11
* @Description: 本地缓存配置
* @Version: 1.0.0
*/
@Configuration
public class GuavaConfig {

    /**
    * @Author: 落雪
    * @Date: 2025/3/14 09:11
    * @Description: 存放access_token防止重复请求
    * @param
    * @Return: com.google.common.cache.Cache<java.lang.String,java.lang.String>
    * @Version: 1.0.0
    */
    @Bean(name = "weixinAccessToken")
    public Cache<String, String> weixinAccessToken() {
        return CacheBuilder.newBuilder()
                .expireAfterWrite(2, TimeUnit.HOURS)
                .build();
    }
    /**
    * @Author: 落雪
    * @Date: 2025/3/14 09:12
    * @Description: 绑定ticket和appid
    * @param
    * @Return: com.google.common.cache.Cache<java.lang.String,java.lang.String>
    * @Version: 1.0.0
    */
    @Bean(name = "openidToken")
    public Cache<String, String> openidToken() {
        return CacheBuilder.newBuilder()
                .expireAfterWrite(1, TimeUnit.HOURS)
                .build();
    }



}
